<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改产品线</title>
</head>
<body>
	<div th:fragment="main" id="modifyProductLine">
		<style type="text/css">
		#modifyProductLine{
	        width: auto;
		    padding: 20px 25px 10px 25px;
		    height: 100%;
		    background-color: #eaeaea;
		    overflow: auto;
		    color: #333;
		}
		.content-title{
		    color: #000;
		    font-size: 14px;
			padding-bottom: 20px;
		}
		.content-title span{
			cursor: pointer;
		}
		.content-bar{
				margin-top:50px; 
			}
		.content-bar .navbar-form{
			padding: 0 5px;
			margin: 0 auto;
		}
		.btn-cyan{
			color: #fff;
			background-color: rgba(26, 156, 178, 1);
			border-color: rgba(26, 156, 178, 1);
		}
		.btn-cyan:hover{
			color: #fff;
			background-color: rgba(25, 109, 123, 0.8);
			border-color: rgba(25, 109, 123, 1);
		}
		.btn-cyan:active{
			color: #fff;
			background-color: rgba(25, 109, 123, 1);
			border-color: rgba(25, 109, 123, 1);
		}
		.btn-cyan:focus{
			color: #fff;
			background-color: rgba(25, 109, 123, 1);
			border-color: rgba(25, 109, 123, 1);
		}
		.btn-bg{
			margin: 0 10px;
			padding: 7px 25px;
		}
		.footer{
			text-align: right;
    		margin-right: 20%;
		}
		#fileupload {
			display: none;
		}
		.form-label{
			width: 17%;
			float: left;
			text-align: right;
		    margin-bottom: 0;
		    padding-top: 7px;
	        padding-left: 15px;
    		padding-right: 15px;
		}
		.form-input{
			width: 25%;
			min-width: 100px;
			height: 34px;
			float: left;
		    padding: 6px 12px;
		    background-color: #fff;
		    border: 1px solid #c2cad8;
		    border-radius: 4px;
		    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
		    box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
		    -webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
		    -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
		    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
		}
		.btn{
			border-radius: 0;
		}
		textarea.form-input{
				height: auto;
		}
		</style>
		<link rel="stylesheet" th:href="@{/assets/jcDate/jcDate.css}">
		<div class="content-title">
	        <p><span>系统管理</span>&nbsp;>&nbsp;<span>修改产品线</span></p>
	    </div>
	   <div class="content-bar">
			<form class="form-horizontal clearfix col-xs-offset-1">
				<div class="form-group">
					<label class="form-label" for="productLineName">产品线名称&nbsp;:&nbsp;</label>
					<input type="text" id="productLineName" class="form-input" placeholder>
				</div>
				<div class="form-group">
					<label class="form-label" for="productLineDescription">备注&nbsp;:&nbsp;</label>
					<textarea id="productLineDescription"  class="form-input" col="0" rows="4" placeholder></textarea>
				</div>
				<div class="form-group">
                    <!-- <input type="button" value="返回" class="btn btn-default pull-right cancel" id="cancel"> -->
                    <!-- <input type="button" value="保存" class="btn btn-primary pull-right save" id="save"> -->
                    <div class="footer">
	                    <a id="save" class="btn btn-cyan btn-bg" role="button">保存</a>
	                    <a class="btn btn-cyan btn-bg" href="#qualitycontrol-systemGroup-productLine" role="button">返回</a>
                    </div>
                </div>
			</form>
	    </div>
	    <script th:src="@{/assets/jcDate/jQuery-jcDate.js}"></script>
	    <script>
	    	// 获取设备类型信息
	    	console.log(productLineData)
			var id = productLineData.id;
			$("#productLineName").val(productLineData.name);
			$("#productLineDescription").val(productLineData.description);
			console.log(productLineData.duplicateTaskFlag)
	        
	        	
			    // 保存
			$('#save').on('click',function(){
                if ($("#productLineName").val().trim().length == 0) {
            		toastr.error("产品线名称不得为空！");
            		return;
            	}
                if ($("#productLineName").val().trim().length > 25) {
            		toastr.error("产品线名称不得超过25个字符！");
            		return;
            	}
                if ($("#productLineDescription").val().trim().length > 250) {
            		toastr.error("备注信息不得超过250个字符！");
            		return;
            	}
        				var formData = {
                            "description": $("#productLineDescription").val().trim(),
                            "name": $("#productLineName").val().trim(),
								"id":id
        					}
        				console.log(formData);		
        				$.ajax({
                            url: contextPath + '/ProductLine/modifyProductLine',
                            type: 'POST',
                            data: JSON.stringify(formData),
                            cache : false,
                            contentType: "application/json",
                            success: function (D) {
                            	if(D.code == 1){
                            		console.log(1)
                                	toastr.success("修改产品线，保存成功!");
                                	console.log(D)
                                	location.hash = "#qualitycontrol-systemGroup-productLine";	
                            	}
                            	else{
                            		toastr.error(D.message);
                            	}
                            },
                            error: function (D) {
                                toastr.error(D.message);
                            }
                        });
        	   	});
	     // 取消
            $('#cancel').on('click',function(){
				$('#add_form')[0].reset();
			});

		</script>
	</div>
</body>
</html>